import 'package:flutter/material.dart';
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
import '../../../common/http/global.dart';
class CreatListView extends StatelessWidget {
  List data = [];

  CreatListView({super.key, required this.data});

  @override
  Widget build(BuildContext context) {
    return SliverMasonryGrid.count(
      childCount: data.length,
      crossAxisCount: 2,
      itemBuilder: (context, index) {
        final Map<String, dynamic> itemData = data[index]; // 获取当前索引对应的data中的元素
        return Container(
          // height: 300,
          color: Colors.white,
          margin: const EdgeInsets.all(5),
          child: Column(
            // crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              FadeInImage(
                  placeholder: const AssetImage('assets/images/testphoto.jpg'),
                  image:
                      NetworkImage("$baseImageUrl${itemData['coverImage']}")),
              Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  if (itemData.containsKey("title") && itemData["title"]!= "")
                    Padding(
                      padding: const EdgeInsets.only(top:5),
                      child: Text(itemData["title"],
                        style:
                            const TextStyle(color: Colors.black, fontSize: 15)),
                    ),
                  Padding(
                    padding: const EdgeInsets.only(top: 5,bottom: 5),
                    child: Row(
                      children: [
                        ClipRRect(
                          borderRadius: BorderRadius.circular(15),
                          child: FadeInImage(
                              fit: BoxFit.cover,
                              width: 30,
                              height: 30,
                              placeholder:
                                  const AssetImage('assets/images/testphoto.jpg'),
                              image: NetworkImage(
                                  "$baseImageUrl${itemData['headImg']}")),
                        ),
                        const SizedBox(width: 5),
                        Column(
                          crossAxisAlignment: CrossAxisAlignment.start,
                          children: [
                            Text(itemData["name"],
                                style: const TextStyle(
                                  fontSize: 12,
                                  color: Colors.black,
                                )),
                            Text(
                              itemData["creatTime"],
                              style: const TextStyle(
                                fontSize: 12,
                                color: Colors.black,
                              ),
                            )
                          ],
                        )
                      ],
                    ),
                  )
                ],
              ),
            ],
          ),
        );
      },
    );
  }
}
